<template>
	<view>
		<u-navbar :autoBack="true" leftIconColor="#fff" title="我的分销" :bgColor="theme == 'light' ? '#0071ff' : '#2c2c2c'"
			:safeAreaInsetTop="true" :placeholder="true" titleStyle="color:#fff">
		</u-navbar>

		<view class="header">
			<view class="">分销团队 - 人</view>
			<view class="">总收益 - 元</view>
		</view>

		<view class="mian">
			<view class="title">我的分销团队</view>

			<!-- <view class="bution">
				<u-grid :border="false">
					<u-grid-item v-for="(baseListItem,baseListIndex) in baseList" :key="baseListIndex">
						<u-icon :customStyle="{paddingTop:20+'rpx'}" :name="baseListItem.name" :size="22"></u-icon>
						<text class="grid-text">{{baseListItem.title}}</text>
					</u-grid-item>
				</u-grid>
				<u-toast ref="uToast" />
			</view> -->
			<view class="content" @click="invitation">
				<view class="item" v-for="item,index in butionList" :key="index">
					<view class="img">
						<u--image :showLoading="true" :src="item.img" width="30px" height="30px"></u--image>
					</view>
					<view class="span">
						<view>{{item.tilie}}</view>
						<view>{{item.spn}}</view>
					</view>
				</view>

			</view>

			<u-tabs :list="list1" @click="clickList">
				
			</u-tabs>
			
			<u-list class="user-invitation-list" @scrolltolower="scrolltolower" @upperThreshold="init" :lowerThreshold="100">
				<u-list-item v-for="(item, index) in DistriList" :key="index">
					<u-cell :title="item.nickname">
						<view class="title" slot="title">{{item.nickname}}</view>
						<u-avatar slot="icon" shape="square" size="35" :src="item.inviterAvatar || '/static/userAvatar.png'"
							customStyle="margin: -3px 5px -3px 0">
						</u-avatar>
						<view class="frequency" slot="value">
							+{{item.giveFrequency}}元
						</view>
					</u-cell>
				</u-list-item>
				<view class="list-tips">
					<!-- {{tips}} -->
				</view>
			</u-list>



			<view class="buttom">
				<u-button type="primary" :plain="true" text="去邀请好友" @click="btnInvite"></u-button>
			</view>


		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: 'https://cdn.uviewui.com/uview/album/1.jpg',
				baseList: [{
						name: 'photo',
						title: '图片'
					},
					{
						name: 'lock',
						title: '锁头'
					},
					{
						name: 'star',
						title: '星星'
					},
					{
						name: 'star',
						title: '音量'
					},
				],
				butionList: [{
						img: require('../../static/ren.png'),
						tilie: '一级分销团队',
						spn: '-人'
					},
					{
						img: require('../../static/income.png'),
						tilie: '团队收益',
						spn: '-元'
					},
					// {
					// 	img: require('../../static/ren2.png'),
					// 	tilie: '二级分销团队',
					// 	spn: '-人'
					// },
					// {
					// 	img: require('../../static/income2.png'),
					// 	tilie: '团队收益',
					// 	spn: '-元'
					// }
				],
				DistriList: [],
				DistriList2: [],
				list1: [{
					name: '一级',
				}, 
				// {
				// 	name: '二级',
				// },
				],

			}
		},
		onLoad() {
			this.getDistri();
		},
		methods: {
			init() {
			
			},
			scrolltolower() {
				// this.page += 1
				// this.getList()
			},
			clickList(item){
				this.DistriList = (item.index)==0 ? this.DistriList2['userInfo1'] : this.DistriList2['userInfo2']
			},
			async getDistri() {
				let {
					data
				} = await uni.$u.http.get(
					`/busi/members/belowSecondLevelInfo?id=${uni.getStorageSync('userInfo').id}`);
				this.DistriList = data.data.userInfo1
				this.DistriList2 = data.data

			},
			//跳转粉丝页面
			invitation() {
				uni.navigateTo({
					url: '/pages/user/invitation'
				})
			},
			//跳转邀请页面
			btnInvite() {
				uni.navigateTo({
					url: '/pages/share/index'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		height: 200rpx;
		background-color: #2193f1;
		color: white;
		font-weight: bold;
		font-size: 30rpx;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
	}

	.mian {
		margin: -20rpx 20rpx 20rpx 20rpx;

		.title {
			background-color: #efefef;
			padding: 20rpx;
		}

		.bution {
			background-color: white;
			height: auto;
			padding: 30rpx;
		}

		.content {
			background-color: white;
			height: auto;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-evenly;
			padding: 20rpx;

			.item {
				width: 280rpx;
				display: flex;
				margin: 20rpx;
				justify-content: center;
				align-items: center;
			}

			.span {
				margin: 10rpx;
				display: flex;
				flex-direction: column;
			}
		}

		.buttom {
			position: absolute;
			bottom: 50rpx;
			width: calc(100% - 40rpx);
		}

	}
</style>